package testing;

import clang.control.CodeBlock;
import clang.control.ExecutionThread;
import clang.control.ReturnStatement;
import clang.control.VariableDefinition;
import clang.data.VarName;
import clang.data.VarType;
import clang.data.Variable;
import clang.functions.Function;
import clang.functions.FunctionCall;
import clang.ops.Operator;

public class MiscTest {

	public static void main(String[] args) {
		
		CodeBlock cb = new CodeBlock(ExecutionThread.get().getCurrentBlock());
		cb.append(new VariableDefinition("a", VarType.INT));
		cb.append(new VariableDefinition("b", VarType.INT));
		cb.append(new VariableDefinition("c", VarType.INT));
		cb.append(new Operator("=", new VarName("a"), new Variable(VarType.INT, 3.0)));
		cb.append(new Operator("=", new VarName("b"), new Variable(VarType.INT, 2.0)));
		cb.append(new Operator("=", new VarName("c"), new Operator("+", new VarName("a"), new VarName("b"))));
		FunctionCall fc = new FunctionCall("dbgprint");
		fc.addParameter(new VarName("a"));
		fc.addParameter(new VarName("b"));
		fc.addParameter(new VarName("c"));
		cb.append(fc);
		cb.append(new ReturnStatement(0));
		
		Function mainFunc = new Function("main");
		mainFunc.setReturnType(VarType.INT);
		mainFunc.setBlock(cb);
		ExecutionThread.get().addFunction(mainFunc);
		
		try {
			//cb.execute();
			ExecutionThread.get().runProgram();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
